<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div :style="{fontSize:fontSize+'px'}">{{pmsg}}</div>
        <menu-item :parr="parr" @enlarge-text="handle($event)"></menu-item>
    </div>
    <script src="../vue.min.js"></script>
    <script>
        Vue.component('menu-item', {
            props: ['parr'],
            template: `
            <div>
                <ul>
                    <li :key='index' v-for='(item,index) in parr'>{{item}}</li>
                <ul>
                <button @click='parr.push("lemon")'>点击</button>
                <button @click='$emit("enlarge-text",5)'>扩大父组件中字体大小</button>
            </div>
        `
        })
        var app = new Vue({
            el: '#app',
            data: {
                pmsg: '父组件中的内容',
                parr: ['apple', 'orange', 'banana'],
                fontSize: 10
            },
            methods: {
                handle: function (val) {
                    this.fontSize += val;
                }
            },
        })
    </script>
</body>

</html>